package com.ruoyi.web.controller.jc;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.JcTeam;
import com.ruoyi.system.service.IJcTeamService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 竞彩球队Controller
 * 
 * @author ruoyi
 * @date 2024-07-20
 */
@Controller
@RequestMapping("/system/team")
public class JcTeamController extends BaseController
{
    private String prefix = "system/team";

    @Autowired
    private IJcTeamService jcTeamService;

    @RequiresPermissions("system:team:view")
    @GetMapping()
    public String team()
    {
        return prefix + "/team";
    }

    /**
     * 查询竞彩球队列表
     */
    @RequiresPermissions("system:team:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(JcTeam jcTeam)
    {
        startPage();
        List<JcTeam> list = jcTeamService.selectJcTeamList(jcTeam);
        return getDataTable(list);
    }

    /**
     * 导出竞彩球队列表
     */
    @RequiresPermissions("system:team:export")
    @Log(title = "竞彩球队", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(JcTeam jcTeam)
    {
        List<JcTeam> list = jcTeamService.selectJcTeamList(jcTeam);
        ExcelUtil<JcTeam> util = new ExcelUtil<JcTeam>(JcTeam.class);
        return util.exportExcel(list, "竞彩球队数据");
    }

    /**
     * 新增竞彩球队
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存竞彩球队
     */
    @RequiresPermissions("system:team:add")
    @Log(title = "竞彩球队", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(JcTeam jcTeam)
    {
        return toAjax(jcTeamService.insertJcTeam(jcTeam));
    }

    /**
     * 修改竞彩球队
     */
    @RequiresPermissions("system:team:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        JcTeam jcTeam = jcTeamService.selectJcTeamById(id);
        mmap.put("jcTeam", jcTeam);
        return prefix + "/edit";
    }

    /**
     * 修改保存竞彩球队
     */
    @RequiresPermissions("system:team:edit")
    @Log(title = "竞彩球队", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(JcTeam jcTeam)
    {
        return toAjax(jcTeamService.updateJcTeam(jcTeam));
    }

    /**
     * 删除竞彩球队
     */
    @RequiresPermissions("system:team:remove")
    @Log(title = "竞彩球队", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(jcTeamService.deleteJcTeamByIds(ids));
    }
}
